Size ================= 计算输入张量或向量的元素总个数(即形状各维度的乘积),并将结果写入输出地址。 输入: - **output** - 输出数据的地址,用于存储计算结果。 - **shape** - 输入张量的形状(维度)数组地址。 - **n** - 输入张量的维度数(Rank)。 - **core_mask** - 核掩码(仅适用于共享存储版本)。 输出: - **output** - 存储元素总个数的地址。 支持平台: ``FT78NE`` ``MT7004`` .. note:: - 由于该算子对于不同数据类型的具体实现一致,因此统一使用 ``size_s`` 和 ``size_p`` 命名,不再区分数据类型前缀(如 ``fp_``, ``i8_`` 等)。 - 支持的数据类型包括:int8, int16, int32, fp32, fp64, cplx64, cplx128。 **共享存储版本:** .. c:function:: void size_s(int* output, int* shape, int n, int core_mask) **C调用示例:** .. code-block:: c :linenos: :emphasize-lines: 13 #include #include int main(int argc, char* argv[]) { int n = 4; // 假设 shape 为 {2, 3, 4, 5},元素总数为 120 int *output = (int *)0xA0000000; int *shape = (int *)0xA0000100; // 实际使用中需确保 shape 地址处已存入维度数据 int core_mask = 0xff; size_s(output, shape, n, core_mask); return 0; } **私有存储版本:** .. c:function:: void size_p(int* output, int* shape, int n) **C调用示例:** .. code-block:: c :linenos: :emphasize-lines: 11 #include #include int main(int argc, char* argv[]) { int n = 3; // 假设 shape 为 {10, 10, 4},元素总数为 400 int *output = (int *)0x10000000; int *shape = (int *)0x10000040; // 实际使用中需确保 shape 地址处已存入维度数据 size_p(output, shape, n); return 0; }